#!/usr/bin/python
from struct import pack
from struct import unpack
from struct import calcsize
import UserStruct
"""Functions to test UserStruct class."""

def test_store(name = 'foo', uid = 0, comp_str = '\x00\x00\x00\x00\x03\x00\x00\x00foo')
	"""Test store function for correct bitstring ouput."""
	obj = UserStruct.UserStruct(name, uid)
	test_str = UserStruct.store(obj)
	if not comp_str == test_str:
		print "UserStruct Error: strings do not match, generated string: `", test_str,"'"

def test_create(name = 'foo', uid = 0, comp_str = '\x00\x00\x00\x00\x03\x00\x00\x00foo')
	"""Test create function for corect nitstring parsing."""
	obj = UserStruct.create(comp_str)
	if not obj.get_user() == name:
		print "FileStruct Error: User does not match, generated:", obj.get_user(), " original:", name
	if not obj.get_id() == uid:
		print "FileStruct Error: ID does not match, generated:", obj.get_id(), " original:", uid

if __name__=='__main__':
	print "UserStruct: Testing store function."
	test_store()
	test_store('Test number 2',123456789,)
	print "UserStruct: Testing create function."
	test_create()
	test_create('Test number 2',123456789,)
